include(CMakeCStdOpt)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-std=c++0x HAS_STD_CPLUSPLUS_0x)
check_cxx_compiler_flag(-std=c++11 HAS_STD_CPLUSPLUS_11)
check_cxx_compiler_flag(-std=gnu++11 HAS_STD_GNU_PLUSPLUS_11)
check_cxx_compiler_flag(-std=gnu++0x HAS_STD_GNU_PLUSPLUS_0x)
check_cxx_compiler_flag(-fPIC CXX_HAS_PIC)
check_cxx_compiler_flag(-Wall HAS_WARN_ALL)

IF(HAS_STD_GNU_PLUSPLUS_11)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
ELSE()
	IF(HAS_STD_CPLUSPLUS_11)
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
	ELSE()
		IF(HAS_STD_GNU_PLUSPLUS_0x)
			set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
		ELSE()
			IF(HAS_STD_CPLUSPLUS_0x)
				set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
			ENDIF()
		ENDIF()
	ENDIF()
ENDIF()

IF(CXX_HAS_PIC)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
ENDIF()

IF(HAS_WARN_ALL)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-sign-compare -Wno-reorder")
ENDIF()

